//package fy.uap.dao;
//
//import java.sql.Connection;
//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//import java.util.List;
//
//import org.apache.commons.logging.LogFactory;
//
//import fy.uap.bean.ApptitudeBean;
//import fy.uap.client.ISupplierOperateStub;
//import fy.uap.client.ISupplierOperateStub.AptitudeList;
//import fy.uap.client.ISupplierOperateStub.VendorAptitude;
//import fy.util.DBUtil;
//import fy.util.MyUtil;
//
//class AptitudeDao {
//	private static org.apache.commons.logging.Log log = LogFactory
//			.getLog(AptitudeDao.class);
//
//	// private static final String newAptitudeSQL =
//	// "insert into fy_supplier_vendor_aptitude (pk_venapt,pk_vendor,pk_invclass,pk_aptclas,startTime,endTime,remark) select substr(sys_guid(),0,20), a.*,?,?,?,? from (select pk_vendor,invclass from (select v.pk_vendor, nvl(i2.pk_invfather,nvl(i2.pk_invclass,nvl(i1.pk_invclass,i.pk_invclass))) invclass from fy_supplier_vendor v left join fy_supplier_vendor_invclass vi on v.pk_vendor = vi.pk_vendor left join fy_supplier_invclass i on i.pk_invclass = vi.pk_invclass left join fy_supplier_invclass i1 on i1.pk_invclass = i.pk_invfather left join fy_supplier_invclass i2 on i2.pk_invclass = i1.pk_invfather where v.cvencode = ? and v.denddate is null and nvl(v.dr,0) = 0 and vi.denddate is null and vi.cvendorclass<>'3')group by pk_vendor,invclass) a where not exists ( select * from fy_supplier_vendor_aptitude s where s.pk_vendor = a.pk_vendor and s.pk_invclass = a.invclass and s.pk_aptclas = ?)";
//	//
//	// public static void newAptitude(Connection conn, List<ApptitudeBean>
//	// beans,
//	// String code, String number) throws Exception {
//	// if (beans != null && beans.size() > 0) {
//	// PreparedStatement pst = null;
//	// try {
//	// pst = conn.prepareStatement(newAptitudeSQL);
//	// for (int i = 0, size = beans.size(); i < size; i++) {
//	// pst.setString(1, beans.get(i).getAptitudeClass());
//	// pst.setString(2, beans.get(i).getStartTime());
//	// pst.setString(3, beans.get(i).getEndTime());
//	// pst.setString(4, beans.get(i).getRemark());
//	// pst.setString(5, code);
//	// pst.setString(6, beans.get(i).getAptitudeClass());
//	//
//	// pst.addBatch();
//	// }
//	// pst.executeBatch();
//	// DBUtil.close(pst);
//	//
//	// pst = conn
//	// .prepareStatement("update fy_supplier_vendor_aptitude a set a.starttime = ?, a.endtime = ?, a.remark = ? where a.dr = 0 and a.pk_aptclas = ? and (a.pk_vendor,a.pk_invclass) in (select pk_vendor,invclass from (select v.pk_vendor, nvl(i2.pk_invfather,nvl(i2.pk_invclass,nvl(i1.pk_invclass,i.pk_invclass))) invclass from fy_supplier_vendor v left join fy_supplier_vendor_invclass vi on v.pk_vendor = vi.pk_vendor left join fy_supplier_invclass i on i.pk_invclass = vi.pk_invclass left join fy_supplier_invclass i1 on i1.pk_invclass = i.pk_invfather left join fy_supplier_invclass i2 on i2.pk_invclass = i1.pk_invfather where v.cvencode = ? and v.denddate is null and nvl(v.dr,0) = 0 and vi.denddate is null and vi.cvendorclass<>'3')group by pk_vendor,invclass)");
//	// for (int i = 0, size = beans.size(); i < size; i++) {
//	//
//	// pst.setString(1, beans.get(i).getStartTime());
//	// pst.setString(2, beans.get(i).getEndTime());
//	// pst.setString(3, beans.get(i).getRemark());
//	// pst.setString(4, beans.get(i).getAptitudeClass());
//	// pst.setString(5, code);
//	// pst.addBatch();
//	// }
//	// pst.executeBatch();
//	// DBUtil.close(pst);
//	//
//	// pst = conn
//	// .prepareStatement("insert into fy_supplier_change_aptitude (PK_CAGAPT, pk_vendor, pk_invclass,pk_aptclas, remark,startTime,endtime,usetime,oacode) select substr(sys_guid(),0,20), a.*, ?,?,?,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),? from (select pk_vendor,pk_invclass,pk_aptclas from (select v.pk_vendor,p.pk_invclass,p.pk_aptclas,max(p.ts) from fy_supplier_vendor_aptitude p left join fy_supplier_vendor v on p.pk_vendor = v.pk_vendor where v.dr = 0 and v.denddate is null and v.cvencode = ? and p.pk_aptclas = ? and p.dr = 0 group by v.pk_vendor,p.pk_invclass,p.pk_aptclas )group by pk_vendor,pk_invclass,pk_aptclas) a");
//	// for (int i = 0, size = beans.size(); i < size; i++) {
//	// pst.setString(1, beans.get(i).getRemark());
//	// pst.setString(2, beans.get(i).getStartTime());
//	// pst.setString(3, beans.get(i).getEndTime());
//	// pst.setString(4, number);
//	// pst.setString(5, code);
//	// pst.setString(6, beans.get(i).getAptitudeClass());
//	// pst.addBatch();
//	// }
//	//
//	// pst.executeBatch();
//	// } catch (Exception e) {
//	// e.printStackTrace();
//	// throw e;
//	// } finally {
//	// DBUtil.close(pst);
//	// }
//	// }
//	// }
//	//
//	// public static void changeAptitude(Connection conn,
//	// List<ApptitudeBean> beans, String code, String number)
//	// throws Exception {
//	// if (beans != null && beans.size() > 0) {
//	// PreparedStatement pst = null;
//	// try {
//	//
//	// pst = conn.prepareStatement(newAptitudeSQL);
//	// for (int i = 0, size = beans.size(); i < size; i++) {
//	// pst.setString(1, beans.get(i).getAptitudeClass());
//	// pst.setString(2, beans.get(i).getStartTime());
//	// pst.setString(3, beans.get(i).getEndTime());
//	// pst.setString(4, beans.get(i).getRemark());
//	// pst.setString(5, code);
//	// pst.setString(6, beans.get(i).getAptitudeClass());
//	// pst.addBatch();
//	// }
//	// pst.executeBatch();
//	// DBUtil.close(pst);
//	//
//	// pst = conn
//	// .prepareStatement("update fy_supplier_vendor_aptitude a set a.starttime = ?, a.endtime = ?, a.remark = ? where a.dr = 0 and a.pk_aptclas = ? and (a.pk_vendor,a.pk_invclass) in (select pk_vendor,invclass from (select v.pk_vendor, nvl(i2.pk_invfather,nvl(i2.pk_invclass,nvl(i1.pk_invclass,i.pk_invclass))) invclass from fy_supplier_vendor v left join fy_supplier_vendor_invclass vi on v.pk_vendor = vi.pk_vendor left join fy_supplier_invclass i on i.pk_invclass = vi.pk_invclass left join fy_supplier_invclass i1 on i1.pk_invclass = i.pk_invfather left join fy_supplier_invclass i2 on i2.pk_invclass = i1.pk_invfather where v.cvencode = ? and v.denddate is null and nvl(v.dr,0) = 0 and vi.denddate is null and vi.cvendorclass<>'3')group by pk_vendor,invclass)");
//	// for (int i = 0, size = beans.size(); i < size; i++) {
//	//
//	// pst.setString(1, beans.get(i).getStartTime());
//	// pst.setString(2, beans.get(i).getEndTime());
//	// pst.setString(3, beans.get(i).getRemark());
//	// pst.setString(4, beans.get(i).getAptitudeClass());
//	// pst.setString(5, code);
//	// pst.addBatch();
//	// }
//	// pst.executeBatch();
//	// DBUtil.close(pst);
//	//
//	// pst = conn
//	// .prepareStatement("insert into fy_supplier_change_aptitude (PK_CAGAPT, pk_vendor, pk_invclass,pk_aptclas, annualinspection,gist,remark,startTime,endtime,usetime,oacode) select substr(sys_guid(),0,20), a.*, ?,?,?,?,?,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),? from (select pk_vendor,pk_invclass,pk_aptclas from (select v.pk_vendor,p.pk_invclass,p.pk_aptclas,max(p.ts) from fy_supplier_vendor_aptitude p left join fy_supplier_vendor v on p.pk_vendor = v.pk_vendor where v.dr = 0 and v.denddate is null and v.cvencode = ? and p.pk_aptclas = ? and p.dr = 0 group by v.pk_vendor,p.pk_invclass,p.pk_aptclas )group by pk_vendor,pk_invclass,pk_aptclas) a");
//	// for (int i = 0, size = beans.size(); i < size; i++) {
//	// pst.setString(1, beans.get(i).getInspection());
//	// pst.setString(2, beans.get(i).getRecord());
//	// pst.setString(3, beans.get(i).getRemark());
//	// pst.setString(4, beans.get(i).getStartTime());
//	// pst.setString(5, beans.get(i).getEndTime());
//	// pst.setString(6, number);
//	// pst.setString(7, code);
//	// pst.setString(8, beans.get(i).getAptitudeClass());
//	// pst.addBatch();
//	// }
//	//
//	// pst.executeBatch();
//	// } finally {
//	// DBUtil.close(pst);
//	// }
//	// }
//	// }
//	public static boolean writeAptitude(Connection conn,
//			List<ApptitudeBean> beans, String code, String number,
//			String userCode) {
//
////		boolean success = false;
////		PreparedStatement pst = null;
////		ResultSet rs = null;
////		try {
////			ISupplierOperateStub sos = new ISupplierOperateStub();
////			AptitudeList alist = new AptitudeList();
////			int size = beans.size();
////			String sql = "select pk_vendor,invclass from (select v.pk_vendor, nvl(i2.pk_invfather,nvl(i2.pk_invclass,nvl(i1.pk_invclass,i.pk_invclass))) invclass from fy_supplier_vendor v left join fy_supplier_vendor_invclass vi on v.pk_vendor = vi.pk_vendor left join fy_supplier_invclass i on i.pk_invclass = vi.pk_invclass left join fy_supplier_invclass i1 on i1.pk_invclass = i.pk_invfather left join fy_supplier_invclass i2 on i2.pk_invclass = i1.pk_invfather where v.cvencode = ? and v.denddate is null and nvl(v.dr,0) = 0 and vi.denddate is null and vi.cvendorclass<>'3')group by pk_vendor,invclass";
////
////			pst = conn.prepareStatement(sql);
////
////			pst.setString(1, code);
////
////			rs = pst.executeQuery();
////
////			while (rs.next()) {
////				String pk_vendor = rs.getString(1);
////				String invclass = rs.getString(2);
////				for (int i = 0; i < size; i++) {
////					ApptitudeBean bean = beans.get(i);
////					// ISupplierOperateStub.Aptitude aptitude = new
////					// ISupplierOperateStub.Aptitude();
////					VendorAptitude va = new VendorAptitude();
////					va.setPk_vendor(pk_vendor);
////					va.setPk_invclass(invclass);
////					va.setPk_aptclas(bean.getAptitudeClass());
////					va.setStartTime(bean.getStartTime());
////					va.setEndTime(bean.getEndTime());
////					va.setRemark(bean.getRemark());
////					va.setGist(bean.getRecord());
////					va.setAnnualInspection(bean.getInspection());
////					va.setOacode(number);
////					va.setOperator(userCode);
////					va.setCreateTime(MyUtil.getNowStr());
////					// aptitude.setVendorAptitude(va);
////					// sos.aptitude(aptitude);
////					alist.addVendorAptitudearrayItem(va);
////
////				}
////			}
////			
////			sos.aptitudeList(alist).get_return();
////
////			success = true;
////		} catch (Exception e) {
////			e.printStackTrace();
////			log.error("供应商资质写入发生异常，单据编号：" + number, e);
////		} finally {
////			DBUtil.close(rs, pst);
////		}
////		return success;
//		return true;
//	}
//}
